/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package client;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

/**
 *
 * @author juan
 */
public class RemoteFile {
    public RemoteFile(String lresp) {

        try {
            //drwxrwxrwx
            //-rw-r--r-- 2 guest None 28449 Dec 9 22:37 Auto Conocimiento.xlsx
            String patternSt = "^([\\-d])([\\-r][\\-w][\\-xs])([\\-r][\\-w][\\-xs])([\\-r][\\-w][\\-xs])\\s+(\\d+)\\s+(\\w+)\\s+(\\w+)\\s+(\\d+)\\s+(\\w+\\s+\\d+\\s+\\d\\d:\\d\\d)\\s+((.*))$";
            Pattern pattern = Pattern.compile(patternSt);
            Matcher m = pattern.matcher(lresp);
            
            
            

            if(m.find()) {
                int i = 1;
                isDirectory = m.group(i++).equals("d");

                uPermitions = m.group(i++);
                gPermitions = m.group(i++);
                oPermitions = m.group(i++);

                m.group(i++); //no lo uso

                owner = m.group(i++);

                group = m.group(i++);

                size = Integer.parseInt(m.group(i++));

                modDate = m.group(i++);

                fileName = m.group(i++);

            } else
                System.out.println("------------------------*-*-*-*-");


        } catch(Exception e) {
            // TODO
            e.printStackTrace();
        }

    }

    public String toString() {
        return fileName;
    }
    public String getName() {
        return fileName;
    }
    public int getSize() {
        return size;
    }
    int size;
    String uPermitions, gPermitions, oPermitions, owner, group, modDate, fileName;
    boolean isDirectory;
}
